
/**
 * Created by JiaJia on 2019/5/22 0022.
 * 数据流中第一个只出现一次的字符
 * 注意是数据流，一直在动态地输入
 */
public class Code55 {
    char[] chars=new char[256];
    StringBuilder sb=new StringBuilder();
    //Insert one char from stringstream
    public void Insert(char ch) {
        sb.append(ch);
        chars[ch]++;
    }
    //return the first appearence once char in current stringstream
    public char FirstAppearingOnce() {
        char[] str=sb.toString().toCharArray();
        for (char c:str) {
            if (chars[c]==1){
                return c;
            }
        }
        return '#';
    }
}